#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int main()
{
	int i = 0;
	int num = 0;
	scanf("%d", &num);
	for (i = 0; i < num; i++)
	{
		int c=0;      //c=1;
		int b = i;
		while (b)   //(b>9)
		{
			b /= 10;   
			c++;
		}
		b = i;
		int sum = 0;
		while (b)
		{
			sum += pow(b % 10, c);
			b /= 10;
		}
		if (sum == i)
		{
			printf("%d   ", i);
		}
	}
}

















